import { http, toast} from '@/uni_modules/uview-plus'

// get请求，首页列表
export const getProducts = (params={}, data={custom:{loading:true,noAuth:true}}) => http.get('/api/products', {...params,...data})


// get请求，商品详情
export const getProductDetail = (id, config = {custom:{loading:true,catch:true,noAuth:true}}) => http.get('/api/product/detail/'+id,config)

export const getCategory = ( config = {custom:{loading:true,catch:true,noAuth:true}}) => http.get('/api/category',config)



//立即购买
export const cartAdd = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/cart/add', params, config)

//订单确认
export const orderConfirm = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/confirm', params, config)

//创建订单
export const orderCreate = (id,params={}, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/create/'+id, params, config)

//计算订单
export const orderComputed = (id,params={}, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/computed/'+id, params, config)


//收货地址列表
export const getAddressList = (config = {custom:{loading:true,catch:true}}) => http.get('/api/address/list', config)

//设置默认收货地址
export const addressDefaultSet = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/address/default/set', params, config)

//删除收货地址
export const addressDel = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/address/del', params, config)

//添加物流地址
export const addressEdit = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/address/edit', params, config)

//获取默认地址
export const getAddressDefault = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/address/default', params, config)

//省市区列表
export const getCityList = (config = {custom:{loading:true,catch:true}}) => http.get('/api/city_list',  config)

//收货地址详情
export const getAddressDetail = (id,config = {custom:{loading:true,catch:true}}) => http.get('/api/address/detail/'+id,  config)

//订单列表
export const getOrderList = (params, config = {custom:{loading:true,catch:true}}) => http.get('/api/order/list',  {...params,...config})

//订单详情
export const getOrderDetail = (id, config = {custom:{loading:true,catch:true}}) => http.get('/api/order/detail/'+id,  config)

//售后订单详情
export const getRefundOrderDetail = (id, config = {custom:{loading:true,catch:true}}) => http.get('/api/order/refund/detail/'+id,  config)

//取消订单
export const orderCancel = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/cancel', params, config)

//详情订单
export const orderRefundInfo = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/refund/cart_info', params, config)

//退货理由
export const orderRefundReason = (config = {custom:{loading:true,catch:true}}) => http.get('/api/order/refund/reason', config)

//提交退款
export const orderRefundApply = (id,params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/refund/apply/'+id, params, config)

//取消退款
export const orderRefundCancel = (id,params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/refund/cancel/'+id, params, config)

//确认收货
export const orderTake = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/take', params, config)

//再次下单
export const orderAgain = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/again', params, config)


//退款订单列表
export const getRefundOrderList = (params, config = {custom:{loading:true,catch:true}}) => http.get('/api/order/refund/list',  {...params,...config})



//支付
export const payApi = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/order/pay', params, config)

//支付详情
export const payInfo = (id, config = {custom:{loading:true,catch:true}}) => http.get('/api/order/cashier/'+id+'/order', config)

//添加购物车
export const setCartNum = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/v2/set_cart_num', params, config)

//统计购物车数量
export const cartCount = (params, config = {custom:{loading:true,catch:true}}) => http.get('/api/cart/count?numType=0', {...params,config})

//获取购物车
export const getCartList = (params, config = {custom:{loading:true,catch:true}}) => http.get('/api/v2/cart_list', {...params,config})

//删除购物车
export const delCart = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/cart/del', params,config)

//删除订单
// export const delCart = (params, config = {custom:{loading:true,catch:true}}) => http.post('/api/cart/del', params,config)


